import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnILMnS/Vspt4NkWSV/1x\n' +
    'a0ldM6nnx2iudxEkSA8pXWv7wsws+HJoFn7Po7gVF2/DtHWg07uC3C9/oZNr1My6\n' +
    'MoE5qQZH1VHdOrbvvwuyd6a87M2rVy1Qz8acSpEqnCMX07YnhUm5ovlYAIHEP30V\n' +
    'kJbKkDo4k0mGWcBscUxyfG39rOObHJz4IKrGNaCrWvBc6C8QyaDA9vAcjqnpTuZO\n' +
    '0vd21N8zsJOmZg/4F+pPXbVGdFQ6HDLk/IIhO9469aka/DAf/hp8chDdER+/tw6c\n' +
    'd5deqcF1C8Mjo5OIRq0qjOGvFHNDT776krd6syQV7sBz++RkNeXCuVqqyipoDun5\n' +
    'tQIDAQAB'

// 加密
export function encrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPublicKey(publicKey) // 设置公钥
    return encryptor.encrypt(txt) // 对数据进行加密
}